package com.yzd.learnjava.generics;

import java.util.Date;

import com.yzd.learnjava.util.Print;

public class Mixins {
	public static void main(String[] args) {
		Mixin mixin1 = new Mixin();
		Mixin mixin2 = new Mixin();
		
		mixin1.set("test string 1");
		mixin2.set("test string 2");
		
		Print.print(mixin1.get() + " " + mixin1.getStamp() + " " + mixin1.getSerialNumber());
		Print.print(mixin2.get() + " " + mixin2.getStamp() + " " + mixin2.getSerialNumber());
	}
}

interface TimeStamped{
	long getStamp();
}

class TimeStampedImpl implements TimeStamped{
	private final long timeStamp ;
	
	public TimeStampedImpl() {
		timeStamp = new Date().getTime();
	}
	public long getStamp() {
		return timeStamp;
	}
}

interface SerialNumbered {
	long getSerialNumber();
}

class SerialedNumberImpl implements SerialNumbered{
	private static  long counter = 1 ;
	private final long serialNumber = counter++;
	public long getSerialNumber() {
		return serialNumber;
	}
	
}

interface Basic {
	public void set(String value);
	public String get();
}

class BasicImpl implements Basic{
	private String value;
	public void set(String value) {
		this.value = value;
	}
	public String get() {
		return value;
	}
}

class Mixin extends BasicImpl implements TimeStamped, SerialNumbered{
	private TimeStamped timeStamped = new TimeStampedImpl();
	private SerialNumbered serialNumbered = new SerialedNumberImpl();
	public long getStamp() {
		return timeStamped.getStamp();
	}
	public long getSerialNumber() {
		return serialNumbered.getSerialNumber();
	}
	
	
}
